<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Employee Information</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/index_work.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".deleteA").click(function () {
                if(confirm("confirm delete?")){
                    $("form").prop("action", $(this).prop("href"));
                    $("form").submit();
                }
                return false;
            });
        });
    </script>
</head>
<body>

    <table>
        <tr>
            <th colspan="6">Employee Information</th>
        </tr>
        <tr>
            <th>ID</th>
            <th>LASTNAME</th>
            <th>EMAIL</th>
            <th>GENDER</th>
            <th>DEPARTMENT</th>
            <th>OPTIONS（<a href="${pageContext.request.contextPath}/toAdd">ADD</a>）</th>
        </tr>
        <c:forEach items="${requestScope.employeeList}" var="emp">
            <tr>
                <td>${pageScope.emp.id}</td>
                <td>${pageScope.emp.lastName}</td>
                <td>${pageScope.emp.email}</td>
                <td>${pageScope.emp.gender==1?"male":"female"}</td>
                <td>${pageScope.emp.department.departmentName}</td>
                <td>
                    <a class="deleteA" href="${pageContext.request.contextPath}/employee/${pageScope.emp.id}">DELETE</a>
                    <a href="${pageContext.request.contextPath}/employee/${pageScope.emp.id}">UPDATE</a>
                </td>
            </tr>
        </c:forEach>
    </table>

    <form method="post">
        <input type="hidden" name="_method" value="DELETE">
    </form>

</body>
</html>
